using AnQinFrameWorkAPI.Entity.Finance.DTO.FinanceUserAccount;
using AnQinFrameWorkAPI.Entity.Finance.View.FinanceUserAccount;
using AnQinFrameWorkAPI.Service.Finance;
using FrameWork.Entity;
using Microsoft.AspNetCore.Mvc;

namespace AnQinFrameWorkAPI.Controllers.Finance;

/// <summary>
///     财务用户账户API
/// </summary>
[Route("api/[controller]")]
[ApiController]
[ApiExplorerSettings(GroupName = "Finance")]
public class FinanceUserAccountController : ControllerBase
{
    //业务接口
    private readonly FinanceUserAccountService _financeUserAccountService;

    //构造注入
    public FinanceUserAccountController(FinanceUserAccountService financeUserAccountService)
    {
        _financeUserAccountService = financeUserAccountService;
    }

    /// <summary>
    ///     获取财务用户账户列表
    /// </summary>
    [ProducesResponseType(typeof(FinanceUserAccountView), 200)]
    [HttpGet]
    public async Task<IActionResult> GetFinanceUserAccountList([FromQuery] FinanceUserAccountSearchDTO financeUserAccountSearchDTO)
    {
        var response = await _financeUserAccountService.GetFinanceUserAccountList(financeUserAccountSearchDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     新增财务用户账户
    /// </summary>
    [HttpPost]
    public async Task<IActionResult> AddFinanceUserAccount([FromBody] FinanceUserAccountAddDTO financeUserAccountAddDTO)
    {
        var response = await _financeUserAccountService.AddFinanceUserAccount(financeUserAccountAddDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     编辑财务用户账户
    /// </summary>
    [HttpPut]
    public async Task<IActionResult> PutFinanceUserAccount([FromBody] FinanceUserAccountUpdateDTO financeUserAccountUpdateDTO)
    {
        var response = await _financeUserAccountService.PutFinanceUserAccount(financeUserAccountUpdateDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     删除财务用户账户
    /// </summary>
    [HttpDelete]
    public async Task<IActionResult> DeleteFinanceUserAccount([FromBody] SingleIdDTO deleteDTO)
    {
        var response = await _financeUserAccountService.DeleteFinanceUserAccount(deleteDTO);
        return StatusCode(response.Status, response);
    }
}